TEnhImage component

Properties	Methods

Unit

EnhImage

Description

The TEnhImage component extends TImage component with JPEG support and image manipulation like flip, invert, saturation, lightness, graying and more. Correctly handles image aspect ratio. Versions for Delphi 16bit & Delphi 32bit.

Requires PASJPG10.ZIP by NOMSSI NZALI Jacques H. C.

Shareware

Please, note that this component is shareware. You can try it to see if it fits your needs but you can't sell nor use it in commercial programs. To make a long story short: you can't gain money through this component.

The component will work correctly while Delphi is running.

The registration fee is, at present, 29 US$ for a single version (16bit or 32bit) and 39 US$ for both versions, but, for updated infos and special offers look on the web.

Over the web, you can find how to register this component at http://ascu.unian.it/~milani/delphi

If the above link should ever be moved, try looking at the DSP (Delphi Super Page) http://sunsite.icm.edu.pl/delphi.

My e-mail address is mc3078@mclink.it or milani@ascu.unian.it.


Properties

AutoSize	ForceOpaque	ShowProgress
BlockSmoothing	Optimize	ScaleStyle
Border	OverSize	Smoothing
Center	Quality	Transparent
ForceGray	ScaleRatio


Methods

Contrastate	LoadJPEG	SavePicture
FlipHorizontal	LoadPicture	ToGray
FlipVertical	ReadImageInfo	VariateColors
Invert	Saturate
Lightness	SaveJPEG


AutoSize

Declaration

property AutoSize: boolean;

Description

Setting this property to TRUE forces the component to change its size to fit the image.


BlockSmoothing

Declaration

property BlockSmoothing: boolean;

Description

Setting this property to TRUE enables block smoothing.


Border

Declaration

property Border: boolean;

Description

If this property is set to TRUE, a border is drawn around the control.

The space for the shown image is reduced accordingly.


Center

Declaration

property Center: boolean;

Description

Setting this property to TRUE causes the image to be centered in the control.


ForceGray

Declaration

property ForceGray: boolean;

Description

This property applies only to JPEG loading. Grays are computed directly by JPEG decoding routines.

Usually you won't use this property and will use ToGray instead.


ForceOpaque

Declaration

property ForceOpaque: boolean;

Description

Setting this property to TRUE will make the control opaque.

That means that repainting it will not cause underlaying controls to be repainted.

This speeds up repainting, but may lead to strange results when the image is changed.


Optimize

Declaration

property Optimize: boolean;

Description

Setting this property to TRUE forces optimization of entropy encoding parameters when saving an image.


OverSize

Declaration

property OverSize: boolean;

Description

If this property is set to TRUE and ScaleStyle is set to ssScale, the image will be enlarged to fit the control (with the right XY ratio).

If set to FALSE, the image won't be enlarged.


Quality

Declaration

property Quality: 0..100;

Description

This property defines the quality to be used when saving to a JPEG file.

Consider that useful values range approximatively from 10 to 90.

A quality value of 85 means almost perfection...


ScaleRatio

Declaration

property ScaleRatio: 0..100;

Description

This property lets you load a smaller image when reading a JPEG file.

A value of 100 means 100% (i.e. normal size). A value of 50 means 50% and so on.

Please note that loading a smaller image usually leads to better results than stretching it later.


ShowProgress

Declaration

property ShowProgress: boolean;

Description

Set this property to TRUE if you want to see the picture while it is loaded from a JPEG file.


ScaleStyle

Declaration

property ScaleStyle: TScaleStyle;

TScaleStyle=(ssNormal,ssScale,ssStretchXY,ssStretchX,ssStretchY);

Description

With this property you can define the appearance of the image in the control.

The most useful option is ssScale. It keeps the right aspect ratio of the image, stretching it to fit the available space in the control. If OverSize is set to FALSE, an image smaller than the control will not be enlarged to fit the control.


Smoothing

Declaration

property Smoothing: 0..100;

Description

This property set the smoothing factor to be used when loading JPEG files.

A value of 0 means that no smoothing will be done.


Transparent

Declaration

property Transparent: boolean;

Description

Setting this property to TRUE forces the color of the left-bottom


Contrastate

Declaration

procedure Contrastate(delta: integer);

Description

Changes the contrast of the image. Valid delta values range from -100 to 100.


FlipHorizontal

Declaration

procedure FlipHorizontal;

Description

Flips the image horizontally.


FlipVertical

Declaration

procedure FlipVertical;

Description

Flips the image vertically.


Lightness

Declaration

procedure Lightness(delta: integer);

Description

Changes the lightness of the image. Valid delta values range from -100 to 100.


Invert

Declaration

procedure Invert;

Description

Inverts the image pixel by pixel. Black becomes white, white becomes black and so on.


LoadJPEG

Declaration

procedure LoadJPEG(const FileName: string);

Description

Loads a JPEG file.


LoadPicture

Declaration

procedure LoadPicture(const FileName: string);

Description

Loads a picture. Chooses the format to be used depending on file extension.


ReadImageInfo

Declaration

procedure ReadImageInfo(const FileName: string; ImageInfo: PEImageInfo);

type PEIImageInfo=^TEIImageInfo;

     TEIImageInfo=record

                    height:integer;

                    width :integer;

                    IsGray:boolean;

                  end;  { record }

Description

Reads informations about the JPEG file specified by FileName.


SaveJPEG

Declaration

procedure SaveJPEG(const FileName: string);

Description

Saves a JPEG file.


SavePicture

Declaration

procedure SavePicture(const FileName: string);

Description

Saves a picture. Chooses the format to be used depending on file extension.


Saturate

Declaration

procedure Saturate(delta: integer);

Description

Changes the saturation of the image. Valid delta values range from -100 to 100.


ToGray

Declaration

procedure ToGray;

Description

Converts the image to gray scale.


VariateColors

Declaration

procedure VariateColors(DeltaSaturation,DeltaContrast,DeltaLightness: integer);

Description

This procedure applies contrast, lightness and saturation changes at once.

It is much faster to apply all of them at once.

This is especially useful when you want to correct a freshly acquired image. Images acquired via VideoCapture and scanners might have colors that need some manipulation to be best viewed on your monitor. You might do some testing to define optimal parameters and then automatically alter every acquired image.